layui.use(['element','form','layer','laydate'], function(){
  var element = layui.element;
  var form = layui.form;
  var index = parent.layer.getFrameIndex(window.name);  
  form.on('submit(formDemo)', function(data){
	    	$.ajax({
				type : 'POST',
				dataType : 'JSON',
				url :  basePath+'/code/save.jhtml',
				data :data.field,
				error : function(XMLHttpRequest, textStatus, errorThrown) {
					parent.layer.msg('系统错误！！', {
						time : 2000
					//2s后自动关闭
					});
				},
				success : function(data) {
					var code = data.responseCode;
					if (code == "1") {
						parent.layer.msg(data.responseMsg, {
							time : 2000
						//2s后自动关闭
						});
					} else {
						parent.layer.msg(data.responseMsg, {
							time : 2000
						//2s后自动关闭
						});
					}

				}
			});
	    parent.layer.close(index);
	    return false;
  });
  
/*  form.on('select(buildingFilter)', function(formData){
  	  $.getJSON(managerPath+"/currency/room/ajaxList.jhtml?buildingId="+formData.value, function(data){
           var optionstring = "";
              	 $.each(data.data, function(i,item){
              		 optionstring += "<option value=\"" + item.id + "\" >" + item.roomName + "</option>";
              	  });
          		 $("#roomId").html(optionstring);
           form.render('select'); //重新渲染
       }); 
  	}); */
  
});